package ex_7_synMoreObjectStaticOneLock;


public class Service {
    synchronized public static void testMethod(){
            try {
                System.out.println("testMethod getLock time=" + System.currentTimeMillis() + " run ThreadName =" +
                        Thread.currentThread().getName());
                Thread.sleep(2000);
                System.out.println("testMethod releaseLock time=" + System.currentTimeMillis() + " run ThreadName =" +
                        Thread.currentThread().getName());
            }catch (Exception e){
                e.printStackTrace();
            }
    }

    public void testMethod2(){
        synchronized (Service.class){
            System.out.println("testMethod2 getLock time=" + System.currentTimeMillis() + " run ThreadName =" +
                    Thread.currentThread().getName());
            System.out.println("testMethod2 releaseLock time=" + System.currentTimeMillis() + " run ThreadName =" +
                    Thread.currentThread().getName());
        }
    }
}
